{include file="header"}
<div style="padding: 20px;" class="adminmyucms">
<form class="layui-form" action="">
<table class="layui-table">
  <colgroup>
  	 <col width="400">
    <col>
  </colgroup>
  <tbody>
    <tr>
      <td><input type="text" name="name" value=""  placeholder="用户名" autocomplete="off" lay-verify="required" class="layui-input"></td>
      <td><input type="text" name="password" value=""  placeholder="密码" autocomplete="off" lay-verify="required" class="layui-input"></td>
      <td>
        <select name="zu" lay-verify="required">
        <option value=""></option>
        {volist name=":fun_s('user_zu',array('open'=>1),'id desc',300,1)" id="vs"}
        <option value="{$vs.id}">{$vs.title}</option>
        {/volist} 
        
      </select>
      </td>
      <td><button class="layui-btn layui-btn-warm" lay-submit lay-filter="set-add">添加管理员</button></td>
    </tr>
  </tbody>
</table>
</form>
<hr style="padding:10px; background-color: #fff">
{volist name="html" id="vo"}
<form class="layui-form" action="">
<input type="hidden" name="id" value="{$vo.id}">	
<table class="layui-table">
  <thead>
    <tr>
      <th>ID</th>
      <th>用户名</th>
      <th>密码</th>
      <th>系统会员组</th>
       <th>操作</th>
    </tr> 
  </thead>
  <tbody>
    <tr  class="layui-form">
      <th>{$vo.id}</th>
      <td><input type="text" name="name" value="{$vo.name}"  placeholder="用户名" autocomplete="off" lay-verify="required" class="layui-input"></td>
      <td><input type="text" name="password" value=""  placeholder="密码 不修改留空即可" autocomplete="off" class="layui-input"></td>
      <td>
        <select name="zu" lay-verify="required">
        <option value=""></option>
        {volist name=":fun_s('user_zu',array('open'=>1),'id desc',300,1)" id="v"}
        <option value="{$v.id}" {if condition="$vo['zu'] eq $v['id']"}selected="selected"{/if}>{$v.title}</option>
        {/volist} 
      </select>
      </td>
      <th>
      	<div class="layui-btn-group">
      		<button class="layui-btn layui-btn-sm layui-btn-normal" style="float: left;" lay-submit lay-filter="set"><i class="layui-icon">&#xe9aa;</i> 修改</button>
      		 <a  member-name="确定要删除这条记录吗?" url="{:url("set/delete")}?id={$vo.id}&m=userAdmin" lay-submit lay-filter="delete"  class="layui-btn layui-btn-danger layui-btn-sm"> <i class="layui-icon">&#xe640;</i>删除</a>
        </div>
      </th>
 
    </tr>
  </tbody>
</table>
</form>
{/volist} 
<div class="pages">
{$html->render()}
<div>
</div> 
<script>
layui.use('form',function(){
  var form = layui.form
  ,jq = layui.jquery;
  //更新
  form.on('submit(set)', function(data){
    loading = layer.load(2, {
      shade: [0.2,'#000']
    });
    var param = data.field;
    jq.post('{:url("user/updateadmin")}',param,function(data){
      if(data.code == 1){
        layer.close(loading);
        layer.msg(data.msg, {icon: 1, time: 1000}, function(){
          //location.href = '{:url("index/index")}';
        });
      }else{
        layer.close(loading);
        layer.msg(data.msg, {icon: 2, anim: 6, time: 1000});
      }
    });
    return false;
  });
  //添加
  form.on('submit(set-add)', function(data){
    loading = layer.load(2, {
      shade: [0.2,'#000']
    });
    var param = data.field;
    jq.post('{:url("user/insertadmin")}',param,function(data){
      if(data.code == 1){
        layer.close(loading);
        layer.msg(data.msg, {icon: 1, time: 1000}, function(){
          location.reload();
        });
      }else{
        layer.close(loading);
        layer.msg(data.msg, {icon: 2, anim: 6, time: 1000});
      }
    });
    return false;
  });
})
layui.use('laydate', function(){
  var laydate = layui.laydate;
  laydate.render({
    elem: '#time'
  });
});
</script>
{include file="footer"}